home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 November / Chip Kasım 2000.iso / prog / share / 11 / setup.exe / %MAINDIR% / DEMOS / CIFTP / LISTFILE / FRMMAIN.FRM (.txt) next >
Encoding:
Visual Basic Form  |  2000-09-07  |  10.3 KB  |  292 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMain 
  3.    Caption         =   "Crescent Internet ToolPak - Receive File"
  4.    ClientHeight    =   6090
  5.    ClientLeft      =   1335
  6.    ClientTop       =   990
  7.    ClientWidth     =   6600
  8.    Height          =   6495
  9.    Left            =   1275
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6090
  12.    ScaleWidth      =   6600
  13.    Top             =   645
  14.    Width           =   6720
  15.    Begin VB.ListBox Files 
  16.       BackColor       =   &H00C0C0C0&
  17.       BeginProperty Font 
  18.          name            =   "Courier New"
  19.          charset         =   0
  20.          weight          =   400
  21.          size            =   9
  22.          underline       =   0   'False
  23.          italic          =   0   'False
  24.          strikethrough   =   0   'False
  25.       EndProperty
  26.       ForeColor       =   &H00800000&
  27.       Height          =   1830
  28.       Left            =   3360
  29.       TabIndex        =   4
  30.       Top             =   960
  31.       Width           =   3135
  32.    End
  33.    Begin VB.ListBox Directories 
  34.       BackColor       =   &H00C0C0C0&
  35.       BeginProperty Font 
  36.          name            =   "Courier New"
  37.          charset         =   0
  38.          weight          =   400
  39.          size            =   9
  40.          underline       =   0   'False
  41.          italic          =   0   'False
  42.          strikethrough   =   0   'False
  43.       EndProperty
  44.       ForeColor       =   &H00800000&
  45.       Height          =   1830
  46.       Left            =   120
  47.       TabIndex        =   3
  48.       Top             =   960
  49.       Width           =   3015
  50.    End
  51.    Begin VB.CommandButton cmdLogin 
  52.       Caption         =   "LOGIN to ftp.progress.com"
  53.       Height          =   375
  54.       Left            =   120
  55.       TabIndex        =   2
  56.       Top             =   120
  57.       Width           =   3015
  58.    End
  59.    Begin VB.CommandButton cmdQuit 
  60.       Caption         =   "QUIT"
  61.       Height          =   375
  62.       Left            =   5040
  63.       TabIndex        =   1
  64.       Top             =   5640
  65.       Width           =   1455
  66.    End
  67.    Begin VB.TextBox txtOutput 
  68.       Height          =   2415
  69.       Left            =   120
  70.       Locked          =   -1  'True
  71.       MultiLine       =   -1  'True
  72.       ScrollBars      =   2  'Vertical
  73.       TabIndex        =   0
  74.       Top             =   3120
  75.       Width           =   6375
  76.    End
  77.    Begin VB.Label lblFiles 
  78.       Caption         =   "Files:"
  79.       BeginProperty Font 
  80.          name            =   "MS Sans Serif"
  81.          charset         =   0
  82.          weight          =   700
  83.          size            =   8.25
  84.          underline       =   0   'False
  85.          italic          =   0   'False
  86.          strikethrough   =   0   'False
  87.       EndProperty
  88.       Height          =   210
  89.       Left            =   3345
  90.       TabIndex        =   6
  91.       Top             =   690
  92.       Width           =   3015
  93.    End
  94.    Begin VB.Label lblDirectories 
  95.       Caption         =   "Directories:"
  96.       BeginProperty Font 
  97.          name            =   "MS Sans Serif"
  98.          charset         =   0
  99.          weight          =   700
  100.          size            =   8.25
  101.          underline       =   0   'False
  102.          italic          =   0   'False
  103.          strikethrough   =   0   'False
  104.       EndProperty
  105.       Height          =   225
  106.       Left            =   120
  107.       TabIndex        =   5
  108.       Top             =   690
  109.       Width           =   3015
  110.    End
  111.    Begin CIFTPLib.CIFTP CIFTP1 
  112.       Height          =   450
  113.       Left            =   3465
  114.       Top             =   105
  115.       Width           =   480
  116.       _Version        =   65537
  117.       _ExtentX        =   847
  118.       _ExtentY        =   794
  119.       _StockProps     =   0
  120.       AccessChannelConnectionWAV=   ""
  121.       AccessChannelClosedWAV=   ""
  122.       DataChannelConnectionWAV=   ""
  123.       DataChannelClosedWAV=   ""
  124.       FileClosedWAV   =   ""
  125.       ListBoxesPopulatedWAV=   ""
  126.       SocketClosedWAV =   ""
  127.       WSAErrorWAV     =   ""
  128.       HostName        =   "ftp.progress.com"
  129.       HostAddress     =   ""
  130.       RemoteFileName  =   ""
  131.       LoginName       =   "anonymous"
  132.       Password        =   "stephenc@progress.com"
  133.       RepresentationType=   ""
  134.       WorkingDirectory=   "/"
  135.    End
  136. Attribute VB_Name = "frmMain"
  137. Attribute VB_Creatable = False
  138. Attribute VB_Exposed = False
  139. ' flag which indicates when TRUE
  140. ' we want to see a directory listing
  141. Dim bDirList As Boolean
  142. Sub OutputText(sText As String)
  143. On Error Resume Next
  144. txtOutput.Text = txtOutput.Text & sText
  145. If Err = 7 Then
  146.   'Out of memory. Remove some data from the beginning of the text
  147.   'box to make room for the new data.
  148.   On Error GoTo 0
  149.   txtOutput.Text = Mid$(txtOutput.Text, Len(sText) + 1) & sText
  150. End If
  151. txtOutput.SelStart = Len(txtOutput.Text)
  152. End Sub
  153. Private Sub CIFTP1_AccessControlChannelClosed()
  154.   ' the access control channel has been closed
  155.   OutputText "AccessControlChannelClosed" + vbCrLf
  156. End Sub
  157. Private Sub CIFTP1_AccessControlChannelConnection()
  158.   ' the access control channel connection has been established
  159.   OutputText "AccessControlChannelConnection" + vbCrLf
  160.   ' Once we have established an access channel we
  161.   ' can login to the FTP server and get a data port
  162.   ' so we can establish a data channel connection
  163.   CIFTP1.USER   ' send the user name -- found in the LoginName property
  164.   CIFTP1.PASS   ' send the password -- found in the Password property
  165.   CIFTP1.PWD    ' update the WorkingDirectory property
  166.   CIFTP1.PASV   ' call pasv -- this requests a data port from the ftp server.
  167.                           ' If successfull the DataPort property is set and the DataPortSet event fires
  168. End Sub
  169. Private Sub CIFTP1_AccessControlPacketReceived(ByVal Packet As String)
  170.   ' packet received on the access control channel
  171.   OutputText Packet
  172. End Sub
  173. Private Sub CIFTP1_DataControlChannelClosed()
  174.   ' the FTP server has closed the data control channel
  175.   OutputText "DataControlChannelClosed" + vbCrLf
  176. End Sub
  177. Private Sub CIFTP1_DataControlChannelConnection()
  178.   ' we have connected to the data channel
  179.   ' we can now invoke ftp methods that move data across
  180.   ' the data channel (LIST, RETR, STOR, etc.)
  181.   OutputText "DataControlChannelConnection" + vbCrLf
  182.   ' if the directories flag is set, then request a dir listing via LIST method...
  183.   If bDirList = True Then
  184.     ' clear the listboxes so we can fill them
  185.     Directories.Clear
  186.     Files.Clear
  187.      
  188.     ' change the form caption to the FTP server working directory
  189.     frmMain.Caption = CIFTP1.WorkingDirectory
  190.     ' issue the file/directory list request
  191.     ' this updates both the list boxes and the files collection
  192.     CIFTP1.List
  193.   Else ' otherwise retrieve a file...
  194.     CIFTP1.RETR ' Note, you must set the LocalFileName and RemoteFileName properties before invoking this method
  195.   End If
  196. End Sub
  197. Private Sub CIFTP1_DataPortSet()
  198.   ' the data port has been assigned by the FTP server
  199.   OutputText "DataPortSet" + vbCrLf
  200.   OutputText LTrim$(Str$(CIFTP1.DataPort)) + vbCrLf
  201.   ' wait...
  202.   Screen.MousePointer = 11
  203.   ' we must find update the ServerOSType by
  204.   ' calling CITCP1.SYST
  205.   'CIFTP1.SYST 'Obsolete as of version 3
  206.   ' now that we have a data port assigned, we can
  207.   ' request a data channel connection
  208.   CIFTP1.ConnectToDataChannel
  209. End Sub
  210. Private Sub CIFTP1_FileClosed()
  211.   ' we're ready for the next request
  212.   Screen.MousePointer = 0
  213.   If bDirList = False Then
  214.     MsgBox ("GET File Completed")
  215.   End If
  216.   ' the incoming stream has been closed
  217.   OutputText "FileClosed" + vbCrLf
  218.   ' we expect ASCII data
  219.   CIFTP1.RepresentationType = "A"
  220.   CIFTP1.TYPE
  221.   ' we expect a directory listing
  222.   bDirList = True
  223.   ' make sure we set the local file name
  224.   ' even for directory listings
  225.   CIFTP1.LocalFileName = "C:\$$$DIR.DAT"
  226. End Sub
  227. Private Sub CIFTP1_SocketClosed()
  228.   ' the socket has been closed
  229.   OutputText "SocketClosed" + vbCrLf
  230. End Sub
  231. Private Sub CIFTP1_WSAError(ByVal error_number As Integer)
  232. ' If this event fires, then an error has occured, so output an error message
  233. Dim ErrString As String
  234. Dim ErrConstDescription As String
  235. Dim ErrDescription As String
  236. ErrDescription = WSAErrDescription(error_number, ErrConstDescription)
  237. ErrString = "WinSock error " & Format$(error_number, "") & ", " & ErrConstDescription & ": " & ErrDescription & vbCrLf
  238. OutputText ErrString
  239. End Sub
  240. Private Sub cmdQuit_Click()
  241.   ' break the FTP server connect and
  242.   ' enable the login button
  243.   CIFTP1.QUIT
  244.   cmdLogin.Enabled = True
  245.   End
  246. End Sub
  247. Private Sub cmdLogin_Click()
  248.   ' make form caption = HostName
  249.   frmMain.Caption = CIFTP1.HostName
  250.   ' we are in the process of connecting
  251.   cmdLogin.Enabled = False
  252.   ' set the listboxes to be filled
  253.   Set CIFTP1.DirectoryListBoxName = Directories
  254.   Set CIFTP1.FileListBoxName = Files
  255.   ' connect to access control channel
  256.   CIFTP1.ConnectToAccessControlChannel
  257. End Sub
  258. Private Sub Directories_DblClick()
  259.   ' a directory selection has been made
  260.   ' now update the listboxes
  261.   If Screen.MousePointer = 0 Then
  262.     If Directories.List(Directories.ListIndex) = ".." Then
  263.       CIFTP1.WorkingDirectory = ".."
  264.       CIFTP1.CWD
  265.     ElseIf Directories.List(Directories.ListIndex) = "." Then
  266.       ' don't do anything
  267.     Else
  268.       CIFTP1.WorkingDirectory = Directories.List(Directories.ListIndex)
  269.       CIFTP1.CWD
  270.     End If
  271.     CIFTP1.PWD
  272.     CIFTP1.PASV ' call pasv -- this requests a data port from the ftp server.
  273.                           ' If successfull the DataPort property is set and the DataPortSet event fires
  274.   End If
  275. End Sub
  276. Private Sub Form_Load()
  277. '-----------------------------------------------------------------------
  278. ' SUBJECT:     ListFile.VBP
  279. ' AUTHOR:      Stephen R. Casella
  280. '              Progress Software Corporation
  281. '              Crescent Division
  282. ' REVISED:     March 12, 1996 - sc
  283. ' DESCRIPTION: Lists files found on the Progress Software Corporation
  284. '              FTP server for a specified directory.
  285. '------------------------------------------------------------------------
  286.   ' center main form on the screen
  287.   Me.Top = (Screen.Height - Me.Height) \ 2
  288.   Me.Left = (Screen.Width - Me.Width) \ 2
  289.   ' we want to see a directory listing, so set flag
  290.   bDirList = True
  291. End Sub
  292.